<?php

class tsw_thermometer implements ThermdSingleWidget
{
  public function drawWidget($io,$x,$y)
  {	
    $black = imagecolorallocate($io,0,0,0);
		$maxmin = ThermdStats::ts_getMaxMin(ThermdStats::$temperature_log_id);
		$grey = imagecolorallocate($io,80,80,80);
		
		$uparrow = imagecreatefrompng(ThermdStats::$thermosrc.'therm-U.png');
		$downarrow = imagecreatefrompng(ThermdStats::$thermosrc.'therm-D.png');
		$thermometer = imagecreatefrompng(ThermdStats::$thermosrc.'thermometer.png');

    if($maxmin!==FALSE)
    {
      imagecopy($io,$thermometer,$x+51,$y,0,0,39,175);
    
  		imagestring($io,1,$x+4,$y+12,"24HR HIGH",$grey);
  		imagestring($io,1,$x+13,$y+21,date('H:i',$maxmin[3]),$grey);
  		imagestring($io,1,$x+7,$y+133,"24HR LOW",$grey);
  		imagestring($io,1,$x+16,$y+142,date('H:i',$maxmin[2]),$grey);
  		
  		imagestring($io,5,$x+94,$y+72,ThermdStats::ts_readCurrent(ThermdStats::$temperature_log_id).ThermdStats::$units,$black);
  		imagestring($io,1,$x+95,$y+16,$maxmin[1].ThermdStats::$units,$grey);
  		imagestring($io,1,$x+95,$y+137,$maxmin[0].ThermdStats::$units,$grey);
  		
  		$currenttrend = ThermdStats::ts_currentTrend(ThermdStats::$temperature_log_id);
  		switch($currenttrend)
  		{
  			case "U":
  				imagestring($io,1,$x,$y+76,"RISING",$black);
  				imagecopy($io,$uparrow,$x+37,$y+72,0,0,13,14);
  			break;
  			case "D":
  				imagestring($io,1,$x,$y+76,"FALLING",$black);
  				imagecopy($io,$downarrow,$x+37,$y+72,0,0,13,14);
  			break;
  			case "S":
  				imagestring($io,1,$x+17,$y+76,"STEADY",$black);
  			default:
  			break;
  		}
		}
  }
}

?>